package assignment1;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Collections;

import util.EasyInput;

import javax.swing.*;

public class ProConPanel  extends JPanel {

	private JTextArea text;
	private JButton pro;
	private JButton con;
	private JLabel title;
	public ArrayList<Integer> randNums2;
	public int xi = 0;
	public ArrayList<Integer> randNums4;
	public int yi = 0;
	
	public ProConPanel() {
		setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
		title = new JLabel("Decision Assister");
		title.setFont(new Font("Serif", Font.ITALIC, 16));

		JPanel titlePanel = new JPanel();
		titlePanel.add(title);
		titlePanel.setBackground(Color.LIGHT_GRAY);
		this.add(titlePanel);

		text = new JTextArea(10, 40);
		text.setLineWrap(true);
		text.setEditable(false);
		JScrollPane scrollPane = new JScrollPane(text);
		
		JPanel textPanel = new JPanel();
		textPanel.add(Box.createRigidArea(new Dimension(20, 0)));
		textPanel.add(text);
		textPanel.add(Box.createRigidArea(new Dimension(20, 0)));
		this.add(textPanel);

		pro = new JButton("Pro");
		pro.setBackground(Color.LIGHT_GRAY);
		pro.addActionListener(new ProListener());
		JPanel proPanel = new JPanel();
		proPanel.add(pro);
		proPanel.setBackground(Color.black);
		this.add(pro);
		
		con = new JButton("Con");
		con.setBackground(Color.LIGHT_GRAY);
		con.addActionListener(new ConListener());
		JPanel conPanel = new JPanel();
		conPanel.add(con);
		conPanel.setBackground(Color.black);
		this.add(con);
		
		JPanel procon = new JPanel();
		procon.add(pro);
		procon.add(Box.createRigidArea(new Dimension(10, 0)));
		procon.add(con);
		this.add(procon);
		
	}
	
	private class ProListener implements ActionListener {
		public void actionPerformed(ActionEvent event) {
			ArrayList<String> pros = new ArrayList<String>();
			pros.add("There is nothing either good or bad, but thinking makes it so. " +
				"- William Shakespeare");
			pros.add("The only job where you start at the top, is digging a hole." +
				"- Anonymous");
			pros.add("A wise man will make more opportunities than he finds. " +
				"- Francis Bacon");
			pros.add("Goals are the fuel in the furnace of achievement. " +
				"- Brian Tracy");
			pros.add("We would accomplish many more things if we did not think of them as impossible. " +
				"- C. Malesherbes");
			pros.add("Don't let what you can't do interfere with what you can do. " +
				"- Anonymous");
			pros.add("The future is not a gift - it is an achievement. " +
				"- Harry Lauder");
			if (xi == 7) {
				xi = 0;
			}
			if (xi == 0) {
				ArrayList<Integer> randNums = new ArrayList<Integer>();
				for(int i = 0; i <= 6; ++i) {
					randNums.add(i);
				}
				Collections.shuffle(randNums);
				text.setText(pros.get(randNums.get(xi)));
				randNums2 = randNums;
			}
			if (xi >=1) {
				text.setText(pros.get(randNums2.get(xi)));
			}
			xi = xi + 1;
		}
	}
	
	private class ConListener implements ActionListener {
		public void actionPerformed(ActionEvent event) {
			ArrayList<String> cons = new ArrayList<String>();
			cons.add("If you think nobody cares about you, try missing a couple of payments. " +
				"- Anonymous");
			cons.add("If at first you don't succeed, destroy all evidence that you tried." +
				"- Anonymous");
			cons.add("The best things in life are already taken." +
				"- Anonymous");
			cons.add("If at first you don't succeed...don't act surprised." +
				"- Anonymous");
			cons.add("The first step to failure is trying." +
				"- Anonymous");
			cons.add("Practice makes perfect, but nobody is perfect so, why practice." +
				"- Anonymous");
			cons.add("Remember things are never so bad that they can't get worse." +
				"- Anonymous");
			if (yi == 7) {
				yi = 0;
			}
			if (yi == 0) {
				ArrayList<Integer> randNums3 = new ArrayList<Integer>();
				for(int s = 0; s <= 6; ++s) {
					randNums3.add(s);
				}
				Collections.shuffle(randNums3);
				text.setText(cons.get(randNums3.get(yi)));
				randNums4 = randNums3;
			}
			if (yi >=1) {
				text.setText(cons.get(randNums4.get(yi)));
			}
			yi = yi + 1;
		}
	}
}
	